package com.zxl.live.screen.screen.ui.widget.panel.heart;

public class Vector {

	public float x;
	
	public float y;

	public Vector(float x, float y) {
		this.x = x;
		this.y = y;
	}
	
	public Vector rotate(float theta) {
		float x = this.x;
		float y = this.y;
		this.x = (float) (Math.cos(theta) * x - Math.sin(theta) * y);
		this.y = (float) (Math.sin(theta) * x + Math.cos(theta) * y);
		return this;
	}
	
	public Vector mult(float f) {
		this.x *= f;
		this.y *= f;
		return this;
	}
	
	public Vector clone() {
		return new Vector(this.x, this.y);
	}
	
	public int length() {
		return (int) Math.sqrt(this.x * this.x + this.y * this.y);
	}
	
	public Vector subtract(Vector v) {
		this.x -= v.x;
		this.y -= v.y;
		return this;
	}
	
	public Vector set(Vector v) {
		this.x = v.x;
		this.y = v.y;
		return this;
	}
	
	public Vector set(float x, float y) {
		this.x = x;
		this.y = y;
		return this;
	}
}
